﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Eserciziotep4
{
    static class Gestione_File
    {
        static string Pacht = @"c:\document\pippo\";
        static string NomeFile = @"text.dat";
        static string Pachtd = Pacht + NomeFile;

        public static void MakeDirecotry()
        {
            try
            {
                Directory.CreateDirectory(Pacht);
                FileStream fs = File.Create(Pachtd);
                fs.Close();

            } catch (IOException e)
            {
                Console.WriteLine(e.Message);
            }

        }
        public static void Scrivi(string nome,string cognome)
        {
            try
            {
                //FileStream fe = File.OpenWrite(Pachtd);
                BinaryWriter bw = new BinaryWriter(File.Open(Pachtd,FileMode.Open));
                bw.Write(nome);

                bw.Write(cognome);
                bw.Close();
    
            }catch(IOException e)
            {
                Console.WriteLine(e.Message);
            }
        }
        public static string[] Leggi()
        {
            string c1=null;
            string[] p = new string[2];
            try
            {
                //FileStream fe = File.OpenRead(Pachtd);
                BinaryReader br = new BinaryReader((File.Open(Pachtd, FileMode.Open)));
                for (int i = 0; i < 2; i++)
                {
                    c1 = br.ReadString();
                    p[i] = c1;
                }
                br.Close();
               // fe.Close();
            }catch(IOException e)
            {
                Console.WriteLine(e.Message);
            }
            return p;
        }
        
    }
}
